clear all;

cd ..; cd ..; cd ..;
load('code_main_model\6_implied_w_r\computation_results\data.mat','sigma','V_backward','nmkt','pdf_B_forward',...
    'nb','ntheta','nz','gridb','gridtheta','gridz','nb_pdf','ntheta_pdf','gridb_pdf','gridtheta_pdf');
load('code_main_model\6_implied_w_r\input\comm_loc_model.mat','comm_loc_model');
cd 'code_figure_table\maintext\Figure 11';

index=find(comm_loc_model(:,4)==0 & comm_loc_model(:,5)==1); % new branch in 1990

marketindex=index(1);
thetaindex=ntheta;
t_ini=1;
t_end=11;
V_ini=squeeze(V_backward(t_ini,marketindex,:,:,thetaindex));
V_new=squeeze(V_backward(t_end,marketindex,:,:,thetaindex));
welfare=(V_new./V_ini).^(1/(1-sigma))-1;
welfare=welfare.*100;

save('baseline\baselineA.mat');